package test;

import entity.Student;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;

/**
 * @author zhu
 * @date 2024-03-26
 */
public class MainTest04 {
    public static void main(String[] args) throws Exception {
        Class<Student> clazz = Student.class;

        Constructor<Student> constructor = clazz.getConstructor(String.class,Double.class);
        Student stu = clazz.getConstructor().newInstance();
        Method studyMethod = clazz.getDeclaredMethod("study",String.class,Double.class);
        studyMethod.setAccessible(true);
        System.out.println("学习获取的经验值：" + studyMethod.invoke(stu, "张三", 80.0));
    }
}
